From db134e958e8853517c4e7463fd3b4590485deee4 Mon Sep 17 00:00:00 2001 From: Joshua DeSeno Date: Tue, 7 Oct 2014 09:25:05 +0900 Subject: [PATCH] Fix warnings for constant names --- src/bin/cargo.rs | 2 +- src/cargo/ops/cargo_new.rs | 4 ++-- src/cargo/ops/cargo_rustc/fingerprint.rs | 6 +++--- src/cargo/ops/cargo_rustc/layout.rs | 10 +++++----- src/cargo/ops/cargo_rustc/mod.rs | 4 ++-- src/cargo/sources/git/utils.rs | 6 +++--- src/cargo/sources/registry.rs | 8 ++++---- tests/support/git.rs | 4 ++-- tests/support/mod.rs | 2 +- tests/support/paths.rs | 6 +++--- tests/test_cargo.rs | 2 +- tests/test_cargo_compile_path_deps.rs | 4 ++-- tests/test_cargo_new.rs | 8 ++++---- tests/test_cargo_registry.rs | 4 ++-- tests/test_cargo_upload.rs | 2 +- 15 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 4f52d482d..5f7e3f352 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -187,7 +187,7 @@ fn list_commands() -> TreeSet { fn is_executable(path: &Path) -> bool { match fs::stat(path) { Ok(io::FileStat{ kind: io::TypeFile, perm, ..}) => - perm.contains(io::OtherExecute), + perm.contains(io::OTHER_EXECUTE), _ => false } } diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index b43b735d5..79191ecaa 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -46,7 +46,7 @@ fn mk(path: &Path, name: &str, opts: &NewOptions) -> CargoResult<()> { try!(HgRepo::init(path)); try!(File::create(&path.join(".hgignore")).write(ignore.as_bytes())); } else if !opts.git && (opts.no_git || cfg.git == Some(false)) { - try!(fs::mkdir(path, io::UserRWX)); + try!(fs::mkdir(path, io::USER_RWX)); } else { try!(GitRepo::init(path)); try!(File::create(&path.join(".gitignore")).write(ignore.as_bytes())); @@ -75,7 +75,7 @@ version = "0.0.1" authors = ["{}"] "#, name, author).as_slice())); - try!(fs::mkdir(&path.join("src"), io::UserRWX)); + try!(fs::mkdir(&path.join("src"), io::USER_RWX)); if opts.bin { try!(File::create(&path.join("src/main.rs")).write_str("\ diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index 9accddf66..3846034da 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -1,7 +1,7 @@ use std::collections::hashmap::{Occupied, Vacant}; use std::hash::{Hash, Hasher}; use std::hash::sip::SipHasher; -use std::io::{fs, File, UserRWX, BufferedReader}; +use std::io::{fs, File, USER_RWX, BufferedReader}; use core::{Package, Target, PathKind}; use util; @@ -166,8 +166,8 @@ pub fn prepare_init(cx: &mut Context, pkg: &Package, kind: Kind) let (_, new1) = dirs(cx, pkg, kind); let new2 = new1.clone(); - let work1 = proc() { try!(fs::mkdir(&new1, UserRWX)); Ok(()) }; - let work2 = proc() { try!(fs::mkdir(&new2, UserRWX)); Ok(()) }; + let work1 = proc() { try!(fs::mkdir(&new1, USER_RWX)); Ok(()) }; + let work2 = proc() { try!(fs::mkdir(&new2, USER_RWX)); Ok(()) }; (work1, work2) } diff --git a/src/cargo/ops/cargo_rustc/layout.rs b/src/cargo/ops/cargo_rustc/layout.rs index 82397d3f5..a9e9ca294 100644 --- a/src/cargo/ops/cargo_rustc/layout.rs +++ b/src/cargo/ops/cargo_rustc/layout.rs @@ -98,7 +98,7 @@ impl Layout { pub fn prepare(&mut self) -> IoResult<()> { if !self.root.exists() { - try!(fs::mkdir_recursive(&self.root, io::UserRWX)); + try!(fs::mkdir_recursive(&self.root, io::USER_RWX)); } if self.old_deps.exists() { @@ -123,10 +123,10 @@ impl Layout { try!(fs::rename(&self.fingerprint, &self.old_fingerprint)); } - try!(fs::mkdir(&self.deps, io::UserRWX)); - try!(fs::mkdir(&self.native, io::UserRWX)); - try!(fs::mkdir(&self.fingerprint, io::UserRWX)); - try!(fs::mkdir(&self.old_root, io::UserRWX)); + try!(fs::mkdir(&self.deps, io::USER_RWX)); + try!(fs::mkdir(&self.native, io::USER_RWX)); + try!(fs::mkdir(&self.fingerprint, io::USER_RWX)); + try!(fs::mkdir(&self.old_root, io::USER_RWX)); for file in try!(fs::readdir(&self.root)).iter() { if !file.is_file() { continue } diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index f1428c57e..64360f910 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -1,6 +1,6 @@ use std::collections::HashSet; use std::dynamic_lib::DynamicLibrary; -use std::io::{fs, UserRWX}; +use std::io::{fs, USER_RWX}; use std::io::fs::PathExtensions; use std::os; @@ -232,7 +232,7 @@ fn compile_custom(pkg: &Package, cmd: &str, try!(if old_output.exists() { fs::rename(&old_output, &output) } else { - fs::mkdir(&output, UserRWX) + fs::mkdir(&output, USER_RWX) }.chain_error(|| { internal("failed to create output directory for build command") })); diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index 03919f45d..3e75d8a8b 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -1,5 +1,5 @@ use std::fmt::{mod, Show, Formatter}; -use std::io::{UserDir}; +use std::io::{USER_DIR}; use std::io::fs::{mkdir_recursive, rmdir_recursive, PathExtensions}; use serialize::{Encodable, Encoder}; use url::Url; @@ -183,7 +183,7 @@ impl GitRemote { if dst.exists() { try!(rmdir_recursive(dst)); } - try!(mkdir_recursive(dst, UserDir)); + try!(mkdir_recursive(dst, USER_DIR)); let repo = try!(git2::Repository::init_bare(dst)); try!(fetch(&repo, url.as_slice(), "refs/heads/*:refs/heads/*")); Ok(repo) @@ -256,7 +256,7 @@ impl<'a> GitCheckout<'a> { fn clone_repo(source: &Path, into: &Path) -> CargoResult { let dirname = into.dir_path(); - try!(mkdir_recursive(&dirname, UserDir).chain_error(|| { + try!(mkdir_recursive(&dirname, USER_DIR).chain_error(|| { human(format!("Couldn't mkdir {}", dirname.display())) })); diff --git a/src/cargo/sources/registry.rs b/src/cargo/sources/registry.rs index 9ce586d4b..9165d50b7 100644 --- a/src/cargo/sources/registry.rs +++ b/src/cargo/sources/registry.rs @@ -94,7 +94,7 @@ impl<'a, 'b> RegistrySource<'a, 'b> { Err(..) => {} } - try!(fs::mkdir_recursive(&self.checkout_path, io::UserDir)); + try!(fs::mkdir_recursive(&self.checkout_path, io::USER_DIR)); let _ = fs::rmdir_recursive(&self.checkout_path); let repo = try!(git2::Repository::init(&self.checkout_path)); Ok(repo) @@ -114,7 +114,7 @@ impl<'a, 'b> RegistrySource<'a, 'b> { if dst.exists() { return Ok(dst) } try!(self.config.shell().status("Downloading", pkg)); - try!(fs::mkdir_recursive(&dst.dir_path(), io::UserDir)); + try!(fs::mkdir_recursive(&dst.dir_path(), io::USER_DIR)); let handle = match self.handle { Some(ref mut handle) => handle, None => { @@ -159,7 +159,7 @@ impl<'a, 'b> RegistrySource<'a, 'b> { pkg.get_version())); if dst.join(".cargo-ok").exists() { return Ok(dst) } - try!(fs::mkdir_recursive(&dst.dir_path(), io::UserDir)); + try!(fs::mkdir_recursive(&dst.dir_path(), io::USER_DIR)); let f = try!(File::open(&tarball)); let mut gz = try!(GzDecoder::new(f)); // TODO: don't read into memory (Archive requires Seek) @@ -168,7 +168,7 @@ impl<'a, 'b> RegistrySource<'a, 'b> { for file in try!(tar.files()) { let mut file = try!(file); let dst = dst.dir_path().join(file.filename_bytes()); - try!(fs::mkdir_recursive(&dst.dir_path(), io::UserDir)); + try!(fs::mkdir_recursive(&dst.dir_path(), io::USER_DIR)); let mut dst = try!(File::create(&dst)); try!(io::util::copy(&mut file, &mut dst)); } diff --git a/tests/support/git.rs b/tests/support/git.rs index 010b1da7a..4d9bfacb8 100644 --- a/tests/support/git.rs +++ b/tests/support/git.rs @@ -11,7 +11,7 @@ pub fn repo(p: &Path) -> RepoBuilder { RepoBuilder::init(p) } impl RepoBuilder { pub fn init(p: &Path) -> RepoBuilder { - fs::mkdir_recursive(&p.dir_path(), io::UserDir).unwrap(); + fs::mkdir_recursive(&p.dir_path(), io::USER_DIR).unwrap(); let repo = git2::Repository::init(p).unwrap(); { let mut config = repo.config().unwrap(); @@ -30,7 +30,7 @@ impl RepoBuilder { pub fn nocommit_file(self, path: &str, contents: T) -> RepoBuilder { let dst = self.repo.path().dir_path().join(path); - fs::mkdir_recursive(&dst.dir_path(), io::UserDir).unwrap(); + fs::mkdir_recursive(&dst.dir_path(), io::USER_DIR).unwrap(); File::create(&dst).write_str(contents.as_slice()).unwrap(); self } diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 5eafd281c..4b3ecf9d3 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -183,7 +183,7 @@ pub fn project(name: &str) -> ProjectBuilder { // === Helpers === pub fn mkdir_recursive(path: &Path) -> Result<(), String> { - fs::mkdir_recursive(path, io::UserDir) + fs::mkdir_recursive(path, io::USER_DIR) .with_err_msg(format!("could not create directory; path={}", path.display())) } diff --git a/tests/support/paths.rs b/tests/support/paths.rs index 126fafeaf..97ac8262e 100644 --- a/tests/support/paths.rs +++ b/tests/support/paths.rs @@ -48,7 +48,7 @@ impl PathExt for Path { e => return e, } for path in try!(fs::walk_dir(self)) { - try!(fs::chmod(&path, io::UserRWX)); + try!(fs::chmod(&path, io::USER_RWX)); } fs::rmdir_recursive(self) } else { @@ -57,7 +57,7 @@ impl PathExt for Path { } fn mkdir_p(&self) -> IoResult<()> { - fs::mkdir_recursive(self, io::UserDir) + fs::mkdir_recursive(self, io::USER_DIR) } fn move_into_the_past(&self) -> IoResult<()> { @@ -83,7 +83,7 @@ impl PathExt for Path { Err(io::IoError { kind: io::PermissionDenied, .. }) => {} e => return e, } - try!(fs::chmod(path, stat.perm | io::UserWrite)); + try!(fs::chmod(path, stat.perm | io::USER_WRITE)); fs::change_file_times(path, newtime, newtime) } } diff --git a/tests/test_cargo.rs b/tests/test_cargo.rs index a4ce15a98..6db2f77fa 100644 --- a/tests/test_cargo.rs +++ b/tests/test_cargo.rs @@ -17,7 +17,7 @@ fn fake_executable(proj: ProjectBuilder, dir: &Path, name: &str) -> ProjectBuild mkdir_recursive(&Path::new(path.dirname())).assert(); fs::File::create(&path).assert(); let io::FileStat{perm, ..} = fs::stat(&path).assert(); - fs::chmod(&path, io::OtherExecute | perm).assert(); + fs::chmod(&path, io::OTHER_EXECUTE | perm).assert(); proj } diff --git a/tests/test_cargo_compile_path_deps.rs b/tests/test_cargo_compile_path_deps.rs index 272345575..58c30f820 100644 --- a/tests/test_cargo_compile_path_deps.rs +++ b/tests/test_cargo_compile_path_deps.rs @@ -1,4 +1,4 @@ -use std::io::{fs, File, UserRWX}; +use std::io::{fs, File, USER_RWX}; use support::{ResultTest, project, execs, main_file, cargo_dir}; use support::{COMPILING, RUNNING}; @@ -527,7 +527,7 @@ test!(override_relative { "#) .file("src/lib.rs", ""); - fs::mkdir(&paths::root().join(".cargo"), UserRWX).assert(); + fs::mkdir(&paths::root().join(".cargo"), USER_RWX).assert(); File::create(&paths::root().join(".cargo/config")).write_str(r#" paths = ["bar"] "#).assert(); diff --git a/tests/test_cargo_new.rs b/tests/test_cargo_new.rs index bd25aab41..58b5c99a9 100644 --- a/tests/test_cargo_new.rs +++ b/tests/test_cargo_new.rs @@ -1,4 +1,4 @@ -use std::io::{fs, UserRWX, File, TempDir}; +use std::io::{fs, USER_RWX, File, TempDir}; use std::io::fs::PathExtensions; use std::os; @@ -93,7 +93,7 @@ Usage: test!(existing { let dst = paths::root().join("foo"); - fs::mkdir(&dst, UserRWX).assert(); + fs::mkdir(&dst, USER_RWX).assert(); assert_that(cargo_process("new").arg("foo"), execs().with_status(101) .with_stderr(format!("Destination `{}` already exists\n", @@ -132,7 +132,7 @@ test!(author_prefers_cargo { my_process("git").args(["config", "--global", "user.email", "baz"]) .exec().assert(); let root = paths::root(); - fs::mkdir(&root.join(".cargo"), UserRWX).assert(); + fs::mkdir(&root.join(".cargo"), USER_RWX).assert(); File::create(&root.join(".cargo/config")).write_str(r#" [cargo-new] name = "new-foo" @@ -151,7 +151,7 @@ test!(author_prefers_cargo { test!(git_prefers_command_line { let root = paths::root(); - fs::mkdir(&root.join(".cargo"), UserRWX).assert(); + fs::mkdir(&root.join(".cargo"), USER_RWX).assert(); File::create(&root.join(".cargo/config")).write_str(r#" [cargo-new] git = false diff --git a/tests/test_cargo_registry.rs b/tests/test_cargo_registry.rs index 37342a573..3101d05b7 100644 --- a/tests/test_cargo_registry.rs +++ b/tests/test_cargo_registry.rs @@ -24,7 +24,7 @@ fn cksum(s: &[u8]) -> String { fn setup() { let config = paths::root().join(".cargo/config"); - fs::mkdir_recursive(&config.dir_path(), io::UserDir).assert(); + fs::mkdir_recursive(&config.dir_path(), io::USER_DIR).assert(); File::create(&config).write_str(format!(r#" [registry] host = "{reg}" @@ -62,7 +62,7 @@ fn setup() { } fn dl(path: &str, contents: &[u8]) -> String { let dst = dl_path().join(path); - fs::mkdir_recursive(&dst.dir_path(), io::UserDir).assert(); + fs::mkdir_recursive(&dst.dir_path(), io::USER_DIR).assert(); File::create(&dst).write(contents).unwrap(); cksum(contents) } diff --git a/tests/test_cargo_upload.rs b/tests/test_cargo_upload.rs index a813ef080..7ad46c7cb 100644 --- a/tests/test_cargo_upload.rs +++ b/tests/test_cargo_upload.rs @@ -18,7 +18,7 @@ fn upload() -> Url { Url::from_file_path(&upload_path()).unwrap() } fn setup() { let config = paths::root().join(".cargo/config"); - fs::mkdir_recursive(&config.dir_path(), io::UserDir).assert(); + fs::mkdir_recursive(&config.dir_path(), io::USER_DIR).assert(); File::create(&config).write_str(format!(r#" [registry] host = "{reg}" -- 2.30.2